//
//  LGBreathReportCardView.m
//  HeartDisease_YHJK
//
//  Created by 1234 on 2025/8/6.
//  训练报告-卡片View

#import "LGBreathReportCardView.h"

@implementation LGBreathReportCardView

-(instancetype)initWithTitle:(NSString *)title frame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        [self.layer addSublayer:self.gradientLayer];
        UIImageView *iconView = [[UIImageView alloc]initWithFrame:CGRectMake(viewPix(12), viewPix(15), viewPix(20), viewPix(20))];
        iconView.image = [UIImage imageNamed:[NSString stringWithFormat:@"呼吸训练报告-%@",title]];
        [self addSubview:iconView];
        
        UILabel *titleLabel = [UILabel lableWithText:title colorString:@"#282828" textFont:LGFontWeight(18, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
        titleLabel.frame = CGRectMake(viewPix(40), viewPix(12), viewPix(150), viewPix(25));
        [self addSubview:titleLabel];
        self.titleLabel = titleLabel;
    }
    return self;
}

-(CAGradientLayer *)gradientLayer{
    if(!_gradientLayer){
        _gradientLayer = [CAGradientLayer layer];
        _gradientLayer.frame = CGRectMake(0, 0, Screen_W-viewPix(32), viewPix(150));
        _gradientLayer.startPoint = CGPointMake(0.5, 0);
        _gradientLayer.endPoint = CGPointMake(0.5, 1.0);
        _gradientLayer.colors = @[(__bridge id)[UIColor colorWithString:@"#F2F6FF"].CGColor, (__bridge id)[UIColor colorWithString:@"#FFFFFF"].CGColor, (__bridge id)[UIColor colorWithString:@"#FFFFFF"].CGColor];
        _gradientLayer.locations = @[@(0), @(0.2f), @(1.0f)];
        _gradientLayer.shadowColor = [UIColor colorWithString:@"#B2BDC7"].CGColor;
        _gradientLayer.shadowOffset = CGSizeMake(0, 4);
        _gradientLayer.shadowOpacity = 0.2;
        _gradientLayer.cornerRadius = 10;
    }
    return _gradientLayer;
}

@end
